#ifndef SESSION_H_INCLUDED
#define SESSION_H_INCLUDED

#include <string>
#include <vector>
#include "../user/user.h"
#include "../filetree/filetree.h"
#include "../network/networkengine.h"
#include "../serializer/serializer.h"
#include "../group/group.h"


using namespace std;

class Session
{
    public:
    /* Constructeurs/desctructeur */
    Session( int& argc, char**& argv );
    Session( string );
    ~Session( void );

    /* Accesseurs */
    const User* _currentUser(void) const;
    string _useraddress(void) const;
    const Group* _groups( void ) const;
    const FileTree* _userFiles( void ) const;
    const FileTree* _commonFiles( void ) const;
    const file_tree& _userFilesTree( void ) const;
    const file_tree& _commonFilesTree( void ) const;

    /* Mutateurs */
    void setUserName(string);
    void setPipes(NetworkEngine::Pipes*);
    void setUserHost(string);
    void setPort( unsigned int );
    void setMergeWithUserFiles( const FileTree&);
    void setMergeWithCommonFiles( const FileTree&);

    //Methodes
    int start( string, string, unsigned int );
    // Filesystem
    void indexUserFilesFolder( string );
    // Network
    void sendGroupToAll(void);
    void getFileIndexFromAll(void);
    void getFile(string host, int port, string path, string name);
    // Misc
    void showGroup(void);

    Group* groups;
    NetworkEngine::Pipes* com;

    private:
    /// Les données de l'utilisateur
    User currentUser;
    FileTree userFiles;
    FileTree commonFiles;
    Serializer userSer;
    Serializer commonSer;

    NetworkEngine netengine;

    string userHost;
    int sessionPort;
};


#endif // SESSION_H_INCLUDED
